<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <ui:composition template="/modelo/padrao.xhtml">
        <ui:define name="conteudo">
            <p:panel id="panel" header="Cadastrar Usuário">
                <h:form id="form_usuario">
                    <h:inputHidden id="ih_id" value="#{usuarioBean.usuario.id}"/>

                    <h:panelGrid columns="3">
                        <span>Nome:</span>
                        <p:inputText id="it_nome" 
                                     value="#{usuarioBean.usuario.nome}"
                                     size="45"
                                     required="true"
                                     requiredMessage="Campo Obrigatório"/>
                        <p:message id="msg_nome" for="it_nome" />

                        <span>Login:</span>
                        <p:inputText id="it_login"
                                     value="#{usuarioBean.usuario.email}"
                                     size="45"
                                     required="true"
                                     requiredMessage="Campo Obrigatório"/>
                        <p:message id="msg_login" for="it_login" />

                        <span>Senha:</span>
                        <p:password id="pw_senha"
                                    value="#{usuarioBean.usuario.senha}"
                                    size="30"
                                    match="pw_confirmar"
                                    required="true"
                                    validatorMessage="A senha foi confirmada incorretamente"
                                    requiredMessage="Campo Obrigatório"/>
                        <p:message id="msg_senha" for="pw_senha" />

                        <span>Confirmar Senha:</span>
                        <p:password id="pw_confirmar"
                                    value="#{usuarioBean.usuario.senha}"
                                    feedback="true"
                                    promptLabel="Por favor confirme a senha"
                                    strongLabel="Forte"
                                    goodLabel="Bom"
                                    weakLabel="Fraco"
                                    size="30"
                                    required="true"
                                    requiredMessage="Campo Obrigatório"/>
                        <p:message id="msg_confirmar" for="pw_confirmar"/>

                        <span>Perfil:</span>
                        <p:selectOneMenu id="it_perfil"
                                         value="#{usuarioBean.usuario.perfil}"
                                         required="true"
                                         requiredMessage="Campo Obrigatório">
                            <f:selectItem itemLabel="Selecione" noSelectionOption="true"/>
                            <f:selectItem itemLabel="ADM" itemValue="ROLE_ADM"/>
                            <f:selectItem itemLabel="Secretaria" itemValue="ROLE_SEC"/>
                            <f:selectItem itemLabel="Laboratorista" itemValue="ROLE_LAB"/>
                        </p:selectOneMenu>
                        <p:message id="msg_perfil" for="it_perfil" />
                    </h:panelGrid>

                    <p>
                        <p:commandButton id="cb_salvar"
                                         ajax="false"
                                         value="Salvar"
                                         action="#{usuarioBean.salvar()}"/>
                        <p:button id="bt_cancelar"
                                  value="Cancelar"
                                  outcome="lista_usuario"/>
                    </p>
                </h:form>   
            </p:panel>
        </ui:define>
    </ui:composition>
</html>

